<?php
include('class/class_connect.php');
include('class/class_page.php');
include('class/class_news.php');
include('class/class_address.php');
include('class/class_workdays.php');
include('class/class_rating.php');
include('class/abstract/class_paginator.php');
include('class/abstract/class_mainObjectInfo.php');
include('class/city_rus.php');
include('class/class_checkGetData.php');
$aCheck=new checkGetData(substr($_GET['obj'], 0, 1).'n');
foreach($_GET as $key=>$val)
{
	$_GET[$key]=$aCheck->safetyCheck($val);
}
if($_GET['obj']=='nets')
{
	header('location: fullactscab.php?city='.$_GET['city'].'&id='.$_GET['id'].'&obj=nets');
	exit;
}
if(!($_GET['obj']=='firms' || $_GET['obj']=='malls'))
{
	$aCheck->error();
	$robots='NOINDEX,NOFOLLOW';
}
$aCheck->checkCity($_GET['city']);
$aCheck->checkTableId($_GET['city'], $_GET['news_id']);

session_start();


$aConnect=new connect(substr($_GET['obj'],0,1).'n');
$row=mysql_fetch_array($aConnect->select_all($_GET['city'], "WHERE id='".$_GET['news_id']."'"));
 //echo $row[$_GET['obj'].'id'];
$aConnect=new connect(substr($_GET['obj'],0,1));
$r=mysql_fetch_array($aConnect->select_all($_GET['city'], "WHERE id='".$row[$_GET['obj'].'_id']."'"));
class aFirmPage extends page
{
	var $row=array();
	var $cityRus;
	private $robots;
	function __construct($row=array(), $robots='')
	{		$this->robots=$robots;
		$aConnect=new connect(substr($_GET['obj'],0,1));
		$this->row=$row;
		$this->cityRus=new city_rus_class();
		parent::__construct();
	}
	function title()
	{
		echo 'Новости '.$this->row['name'].' '.$this->cityRus->city_rus_im($_GET['city']);
	}
	function maincontent()
	{
		if($this->row['division'])
		{			$division='
			<div class="routeEl">
				<a href="division.php?city='.$_GET['city'].'&division='.$this->row['division'].'">'.$this->row['division'].'</a>
			</div>';
			$subdiv=$this->row['subdiv'];
		}
		else
		{
			$subdiv='Торговые центры';
		}
		echo ('
		<div class="route">
			<div class="routeEl">
				'.$division.'
			</div>
			<div class="routeEl">
				<a href="'.$_GET['obj'].'_list.php?city='.$_GET['city'].'&subdiv='.$this->row['subdiv'].'">'.$subdiv.'</a>
			</div>
			<div class="routeEl">
				<a href="'.$_GET['obj'].'.php?city='.$_GET['city'].'&id='.$this->row['id'].'">'.$this->row['name'].'</a>
			</div>
			<div class="routeEl">
				Новости
			</div>
		</div>
		');
		$aConnect=new connect(substr($_GET['obj'],0,1).'n');
		$row=mysql_fetch_array($aConnect->select_all($_GET['city'], "WHERE id='".$_GET['news_id']."'"));
		$aFirmInfo=new aFirmInfo($this->row);
		echo '
		<div align="center">
		';
		$news=new news($_GET['obj'], $_GET['city'], $_GET['id']);
		$news->showANews($row['id'], $row['name'], $row['stext'], $row['data'], 'fullnews.php?city='.$_GET['city'].'&obj='.$_GET['obj'].'&id='.$_GET['id'].'&news_id=', 1000);
       // $aPaginator=new newsPaginator();
       echo ('
       </div>
       ');
	}
	function metaData()
	{		($this->robots)?$robots=$this->robots:$robots='INDEX,FOLLOW';
		$description='Новости компании '.$this->row['name'].' в городе '.$this->cityRus->city_rus_im($_GET['city']);
		$keywords='новости, комания, фирма, '.$this->row['name'].', '.$this->cityRus->city_rus_im($_GET['city']).', '.$this->row['subdiv'].',
		'.$this->row['division'].','.$this->row['short'];
		return array('name'=>array('Robots'=>$robots,
 								   'Description'=>$description,
 								   'Keywords'=>$keywords,
 								   ),
 					);	}
}


class aFirmInfo extends mainObjectInfo
{
	var $row;
	function __construct($row=array())
	{
		$this->row=$row;
		parent::__construct();
	}
	function showPic()
	{
		echo ('
		<img src="pictures/'.$_GET['obj'].'pics/'.$_GET['city'].'/'.$this->row['id'].'.jpg" title="'.$this->name.'">
		');
		$aFirmRating=new rating(substr($_GET['obj'],0,1));
		$aFirmRating->rating($_GET['city'], $this->row['id']);
	}
	function showAddress()
	{
		$address=new address();
		if($_GET['obj']=='firms')
			$address->showSeveralAddresses($this->row['address'], $this->row['link']);
		else
		{
			$addr=explode(',', $this->row['address']);
			$explAddress=$addr[0].'^'.$addr[1].'^'.$this->row['phone'].'^^'.$this->row['workdays'];
			$address->showAddress($explAddress,  $this->row['link']);
		}
	}
	function showshort()
	{
		echo $this->row['short'];
	}
	function showName()
	{
		echo $this->row['name'];
	}
}

$aPage=new aFirmPage($r);

?>